package com.javasm.sys.controller;

import com.github.pagehelper.PageInfo;
import com.javasm.commons.base.BaseController;
import com.javasm.commons.entity.AxiosResult;
import com.javasm.commons.entity.OperLogQuery;
import com.javasm.commons.entity.TableDatas;
import com.javasm.commons.enums.OperatorAction;
import com.javasm.commons.enums.OperatorType;
import com.javasm.sys.SysOprateLog;
import com.javasm.sys.SysOprateLogService;
import com.javasm.sys.annotations.MyLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/operlog")
public class OperLogController extends BaseController {
    @Autowired
    private SysOprateLogService oprateLogService;
    @GetMapping
    public TableDatas getLogList(OperLogQuery operLogQuery){
        startPage();
        List<SysOprateLog> l = oprateLogService.getOperList(operLogQuery);
        return toTableDatas(l);
    }

    @DeleteMapping
    @MyLog(title = "日志模块",operationAction = OperatorAction.DELETE,operatorType = OperatorType.MANAGE)
    public AxiosResult batchDelete(Integer[] ids){
        oprateLogService.batchDeleteLogs(ids);
        return AxiosResult.suc();
    }
}
